Imports System.Xml.Serialization
Namespace Mapping

    Public Class EntityTypeMapping
        Inherits XEntityModelElementBase

        ''' <summary>Initializes an instance of the <see cref="EntityTypeMapping" /> class.
        ''' This is the default constructor for this class.</summary>
        Public Sub New()
            MyBase.New("EntityTypeMapping", CSXmlNamespace)
        End Sub

        ''' <summary>Initializes an instance of the <see cref="EntityTypeMapping" /> class.</summary>
        ''' <param name="other">An <see cref="System.Xml.Linq.XElement"/> object to copy from.</param>
        Public Sub New(ByVal other As XElement)
            MyBase.New(other)
        End Sub

        Private __mappingFragment As MappingFragmentCollection

        <AutoLoad()> _
        <XmlElement("MappingFragment", GetType(MappingFragment))> _
        Public ReadOnly Property MappingFragments() As MappingFragmentCollection
            Get
                If (__mappingFragment Is Nothing) Then
                    __mappingFragment = New EdmxEditor.Mapping.MappingFragmentCollection(Me, MyBase.Name.Namespace, "MappingFragment")
                End If
                Return __mappingFragment
            End Get
        End Property

        <AutoLoad()> _
        <XmlElement("ModificationFunctionMapping")> _
        Public Property ModificationFunctionMapping() As EntityTypeModificationFunctionMapping
            Get
                Return DirectCast(Me.Element(MyBase.Name.Namespace + "ModificationFunctionMapping"), EdmxEditor.Mapping.EntityTypeModificationFunctionMapping)
            End Get
            Set(ByVal value As EntityTypeModificationFunctionMapping)
                If (DirectCast(value, XElement).Name <> (MyBase.Name.Namespace + "ModificationFunctionMapping")) Then
                    Throw New ArgumentException("Invalid Element")
                End If
                If (Me.ModificationFunctionMapping IsNot Nothing) Then
                    Me.ModificationFunctionMapping.Remove()
                End If
                Me.Add(New EdmxEditor.Mapping.EntityTypeModificationFunctionMapping(value))
            End Set
        End Property

        <XmlAttribute()> _
        Public Property TypeName() As String
            Get
                Return Me.@TypeName
            End Get
            Set(ByVal value As String)
                Me.@TypeName = value
            End Set
        End Property

    End Class

End Namespace